﻿using System.Dynamic;
using System.Web.Mvc;
using System.Collections.Generic;
using System;

namespace CodeCamp.BL.Model
{
	public static class ModelExtension
	{
		/// <summary>
		/// Decorates a dynamic object with property accessors
		/// </summary>
		/// <param name="c"></param>
		/// <param name="mainValue"></param>
		/// <returns>An ExpandoObject with properties that encapsulate a loading method</returns>
		public static dynamic LazyDecorate(this Controller c, object mainValue)
		{
			dynamic result = new ExpandoObject();
			result.Value = mainValue;
			result.SessionInterest = new Func<Dictionary<string, int>>(CodeCampBL.SessoinInterest);
			result.TagUsage = new Func<Dictionary<string, int>>(CodeCampBL.TagUsage);
			return result;
		}
	}
}
